<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
		<title>淘宝-商品分页</title>
		<link rel="stylesheet" type="text/css" href="css/svg/font.css" />
		<link rel="stylesheet" type="text/css" href="css/shangpin.css" />
		
		<script>
			window.onload = function() {
				document.documentElement.style.fontSize = document.documentElement.clientWidth / 320 * 20 + 'px';
				window.onresize = function() {
					document.documentElement.style.fontSize = document.documentElement.clientWidth / 320 * 20 + 'px';
				}
			}
		</script>
	</head>

	<body>
		<!--标题固定定位开始-->
		<div id="header">
			<a href="zhuye.html" id="goback">
				<</a>
			</a>
			<a href="javascript:;" class="icon-search"></a>
			<a href="javascript:;" class="icon-flickr"></a>
		</div>
		<!--标题固定定位结束-->

		<!--商品图片开始-->
		<section id="picture">
			
			
		</section>
		<!--商品图片结束-->

		<!--商品信息开始-->
		<section class="comm-details">
			<article class="comm-name">
			
			
			</article>
			<article>
				<a href="javascript:;">
					<i class="icon-share2"></i>
					<p>分享</p>
				</a>
			</article>
			<article>
				<p id="qian">¥<span>13</span>.8</p>
				<div>卖家优惠</div>
			</article>
			<p>
				<span id="wei"></span>
				<span>满88包邮(20kg内)</span>
				<span id="you"></span>
			</p>
			<songda>23:00点前付款，预计12月9日(明天)送达，可选送货时间</songda>
		</section>
		<!--商品信息结束-->

		<!--天猫超市促销积分开始-->
		<section class="tianmaochaoshi">
			<img src="img/tianmaochaoshiLogo.jpg" />
			<section>
				<span><img src="img/duihao.jpg"/>一站式购齐</span>
				<span><img src="img/duihao.jpg"/>满88包邮</span>
				<span><a href="javascript:;">></a></span>
			</section>
			<section>
				<article>
					<i>促销</i>
					<span>满99元，省50元;</span>
					<span>满188元，省100元</span>
				</article>
				<article>
					<i>积分</i>
					<span>购买可得1积分</span>
				</article>
				<span><a href="javascript:;">></a></span>
			</section>
		</section>
		<!--天猫超市促销积分结束-->

		<!--配送到开始-->
		<peisong>
			<span>配送至 :&nbsp;&nbsp;大兴区</span>
			<span><a href="javascript:;">></a></span>
		</peisong>
		<!--配送到结束-->

		<!--宝贝评价开始-->
		<div class="zl-pl" id="pj">
			<p>宝贝评价(<zong></zong>)</p>
			<div class="fl">
				<span >好评(<k id="q"></k>)</span>
				<span >中评(<k id="w"></k>)</span>
				<span >差评(<k id="e"></k>)</span>
			</div>
			
			<div class="pinglun">
				
			</div>
			<div class="pl">
				查看商品评价
			</div>
		</div>
		<!--宝贝评价结束-->

		<!--底部加入购物车开始-->
		<footer>
			<a href="javascript:;">
				<i class="icon-star-empty"></i>
				<p>收藏</p>
			</a>
			<a href="../1603B-taobao/gouwuche.html" id="zong">
				<i class="icon-cart"></i>
				<p>总价:<span> ¥13</span></p>
			</a>
			<a id="gouwu">加入购物车</a>
		
		</footer>
		
			<div class="chenggong">
				<span>加入购物车成功</span>
		</div>
		<!--底部加入购物车结束-->

	</body>
	<script type="text/javascript" src="js/jquery-1.11.2.js" ></script>
	<script>
	
	var yl=document.getElementById('zong');
			yl.addEventListener('click',fn4,false)
			 function fn4(){
			 	if(localStorage.user_phone&&localStorage.user_pass_word){
			 		window.location.href='gouwuche.html';
					}else{
						window.location.href="denglu.html";
					}			 	
			 }
			 
			 $("#fan").click(function(){
				window.history.back(-1);
			})
			 
	
	
        var id = window.location.href.split('=')[1];

		$.ajax({
			type: "post",
			url: "http://192.168.1.100/supermarket/data/get_commodity_info.php",
			async: true,
			data: {
				'id': id,
			},
			dataType: 'jsonp',
			jsonp: 'callback',
			jsonpCallback: 'success_JsonpCallback',
			success: function(data) {
				//debugger; //断点

				if(data != null) {
					var html = '';
					html = '<ul id="picUL"><li><img src="http://192.168.1.100/supermarket/img/' + data.img + '" /></li></ul>'
					$('#picture').append(html);
					var htmll = '';
					htmll += '<img src="img/tianmao-xiaoLogo.jpg" />  '+data.name
					$('.comm-name').append(htmll)					
					$("#qian").text("￥"+data.price)
					$("#you").text("月效"+data.count+"笔")
					$("#wei").text(data.weight+"kg")
					//localStorage.i = id;
				}
			},
			error: function(data) {

			}
		})


   　　　　　　　　//加入购物车
			 $("#gouwu").bind("click",function(){			 	
			 	if(localStorage.user_psd && localStorage.user_phone){
				 	$.ajax({
				 		type:"get",				 		
				 		url:"http://192.168.1.100/supermarket/data/my_commodity_car.php",
				 		async:true,
				 		  data: {'user_phone':localStorage.user_phone,'commodity_id':id,'count': 1},		 						 		
				 		dataType:"jsonp",
				 	  jsop:"callback",
				 	  jsonpCallback:"success_JsonpCallback",			 	
				 	  success:function(data){
				 	  //	debugger;
				 	  	if(data.msg=="success"){
				 	  		$(".chenggong").show();
								setTimeout(function(){
									$(".chenggong").hide();
								},1000)
				 	  	};
				 	  	if(data.msg=="error"){
				 	  		$(".chenggong").show();
				 	  		$(".chenggong span").text("提交信息不足")
								setTimeout(function(){
									$(".chenggong").hide();
								},1000)							
				 	  }				 	  	
				 	  },
				 	  error: function(data) {}
				 	});
					}else{
						window.location.href="denglu.html";
					}
			 })
			 


   

 //获取评价数量接口
     $.ajax({
     	type:"get",
     	url: "http://192.168.1.100/supermarket/data/get_commodity_evluate.php",
			data: {'commodity_id': sessionStorage.thisId},
			dataType:"jsonp",
		 	jsop:"callback",
     	async:true,
     	success:function(data){
//   		console.log(data)
     		var data=data;
     		var q=0;
     		var w=0;
     		var e=0;
     		$("zong").text(data.length);
     		for (var i=0;i<data.length;i++) {
     			if(data[i].evaluate==1){
     				q++
     			}else if(data[i].evaluate==2){
     				w++
     			}else{
     				e++
     			}
     		}
     		$("#q").text(q);
     		$("#w").text(w);
     		$("#e").text(e);
     	}
     });
     sessionStorage.thisId = window.location.href.split('=')[1];
     //查看评价接口
     var start=0;
     $(".pl").click(function(){
	     	$.ajax({
					type:"get",
					url:"http://192.168.1.100/supermarket/data/get_commodity_evluate_info.php",
					data: {'commodity_id': sessionStorage.thisId,'start': start},
					dataType:"jsonp",
			 		jsop:"callback",
					async:true,
					success:function(data){
						console.log(data)
						var html="";
						for(var i=0;i<data.length;i++){
						html+='<div class="tij"><span>用户名：'+data[i].user_name+'</span></br>\
				<span>评价：'+data[i].evaluate_info+'</span></div>'
						}
						$(".pinglun").append(html);
						start+=4;
					}
				});
     	
     	
     })


	</script>

</html>